package framework.command.impl;

import framework.account.IAccount;
import framework.account.IEntry;
import framework.command.ICommand;
import framework.factory.TransactionFactory;
/**
 * Default implementation of DepositCommand
 * creates deposit transaction and adds to account transactionHistory
 * Can be extended in order to override execute
 * @author Abdulaziz
 *
 */
public class DepositCommand implements ICommand {
	private IAccount acc;
	private float amount;
	public DepositCommand(IAccount acc, float amount){
		this.acc = acc;
		this.amount = amount;
	}

	public void execute() {
		if(acc.deposit(amount)){
			IEntry tr = TransactionFactory.createDepostiTransaction(amount, "success");
			acc.addTransaction(tr);
		}else{
			IEntry tr = TransactionFactory.createDepostiTransaction(amount, "failed");
			acc.addTransaction(tr);
		}
	}

}
